var dtGridColumns= [{
    id: 'mac',
    title:'串号',
    type: "string",
    columnClass: 'text-center',
    headerStyle: 'color:grey;white-space:nowrap;'
}, {
    id: 'deviceName',
    title:'设备名称',
    type: 'string',
    columnClass: 'text-center',
    headerStyle: 'color:grey; white-space:nowrap;'
},{
    id:'deviceFirm',
    title:'设备厂商',
    type:'string',
    columnClass :'text-center',
    headerStyle:'color:grey; white-space:nowrap;'
},{
    id:'model',
    title:'设备型号',
    type:'string',
    columnClass :'text-center',
    headerStyle:'color:grey; white-space:nowrap;'
},{
    id:'owner',
    title:'拥有人',
    type:'string',
    columnClass :'text-center',
    headerStyle:'color:grey; white-space:nowrap;'
},{
    id:'insertTime',
    title:'插入时间',
    type:'date',
    format:'yyyy-MM-dd',
    otype:'time_stamp_ms',
    oformat:'string',
    columnClass : 'text-center',
    headerStyle : 'color:grey;',
    hideType : 'xs|sm|md|lg',
},{
    id:'insertPerson',
    title:'新增人员',
    type:'string',
    columnClass :'text-center',
    headerStyle:'color:grey; white-space:nowrap;',
},{
    id:'updateTime',
    title:'修改时间',
    type:'date',
    format:'yyyy-MM-dd',
    otype:'time_stamp_ms',
    oformat:'string',
    columnClass : 'text-center',
    headerStyle : 'color:grey;',
    hideType : 'xs|sm|md|lg',
},{
    id:'updatePerson',
    title:'修改人',
    type:'string',
    columnClass :'text-center',
    headerStyle:'color:grey; white-space:nowrap;',
},{
    id : 'operation',
    title : '操作',
    type : 'string',
    columnClass : 'text-center tpl-table-black-operation',
    headerStyle : 'color:grey; white-space:nowrap; padding: 0px 20px;',
    resolution:function(value, record, column, grid, dataNo, columnNo){
        var content = '';
        content += '<a href="#" onclick="loadPage(\'device/'+record.id+'/select\');"> <i class="am-icon-pencil"></i> 编辑</a> ';
        return content;
    }
}]
var dtGridOption = {
    lang : 'zh-cn',
    ajaxLoad : true,
    check : true,
    checkWidth :'37px',
    loadURL : 'device/list',
    columns : dtGridColumns,
    gridContainer : 'dtGridContainer',
    toolbarContainer : 'dtGridToolBarContainer',
    tools : '',
    pageSize : 10, //默认每页十条记录
    pageSizeLimit : [10, 20, 30] //分页选项：每页10、20\或者30条记录
};
var grid = $.fn.dlshouwen.grid.init(dtGridOption);


$(function() {
    grid.load();
    $('select').selected();
});

function search(){
    grid.parameters = new Object();
    grid.parameters['title'] = $("#title").val();
    grid.refresh(true);
}

function delteAll(){
    var checkId = getCheckAll(grid.getCheckedRecords());
    if(checkId!=''){
        del("device/"+checkId+"/deleteBatch",search);
    }else{
        layer.msg('请选择要删除的数据', {
            icon : 3
        });
    }
}